#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n, l, r;
int main(){
	freopen("candy.in", "r", stdin);
	freopen("candy.out", "w", stdout);
	scanf("%d %d %d", &n, &l, &r);
	if(l % n == 0){
		if(r >= l + n - 1){
			printf("%d\n", n - 1);
			return 0;
		}
		printf("%d\n", r % n);
		return 0;	
	}
	if(r < (l + n - 1) / n * n - 1){
		printf("%d\n", r % n);
		return 0;
	}
	printf("%d\n", n - 1);
	return 0;
}

